package com.xiaren.common;

import java.awt.Color;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;

import javax.swing.JLabel;

/**
 * @主页 http://www.leaf123.cn/
 * @邮箱 xia5523@qq.com
 */
public class IConstant {
	public static final String CHAR_WORD = "abcdefghijklemnoprstuvwxyzABCDEFGHIJKLEMNOPRSTUVWXYZ";
	public static Color toolColor = new Color(191, 219, 255);// 工具栏背景色
	public static Color dirColor = new Color(237, 237, 237);// 目录背景色
	public static Color textPaneColor = new Color(199, 237, 204);// 文本编辑器背景色

	public static String[] keyword = null;
	public static Properties loyoutProperties;// 当前界面样式模式等的属性资源文件
	public static Properties utilProperties;// 关键字属性资源文件
	public static Properties filenameProperties;// 用于存储文件名称类型的
	public static Properties keyProperties;// 密码存储

	// properties属性常量
	public static final String WIDTH = "width";
	public static final String HEIGHT = "height";
	public static final String LOCALX = "localX";
	public static final String LOCALY = "localY";

	static final String BASE_PATH =
			"note_file";
//			"E:\\工作空间\\git_work\\my_use\\note_file";

	public static final String TOOLS_PATH = BASE_PATH + "\\res\\tools";

	public static final String PATH_TREE_FILE = BASE_PATH + "\\treedir.txt";
	static final String LOYOUTFILE = BASE_PATH + "\\res\\loyout.properties";
	static final String UTILFILE = BASE_PATH + "\\res\\util.properties";
	static final String FILENAME = BASE_PATH + "\\res\\filename.properties";
	static final String KEYFILE = BASE_PATH + "\\res\\key.properties";
	public static final String NOTETITLE = BASE_PATH
			+ "\\res\\image\\title.png";
	public static final String FLOATIMAGE = BASE_PATH
			+ "\\res\\image\\float.png";
	public static final String PATH = BASE_PATH + "\\res\\data\\document\\";// 文件路劲
	public static final String IMAGE_PATH = BASE_PATH + "\\res\\data\\image\\";// 文件路劲


	public static final int TOOLBAR_HEIGHT = 25; // toolbar高度
	public static final int LEFTPANEL_WIDTH = 200; // toolbar宽度

	public static final String JFRAME_TITLE = "note soft";

	public static String FILETYPE_TEXT = "text";// 文件的文本类型
	public static String FILETPE_TABLE = "table";// 文件的table类型

	public static String INIT_PASSWORD = "xia5523";// 文件的table类型初始化密码

	static {

		loyoutProperties = new Properties();
		utilProperties = new Properties();
		filenameProperties = new Properties();
		keyProperties = new Properties();

		try {
			loyoutProperties.load(new BufferedInputStream(new FileInputStream(
					LOYOUTFILE)));
			utilProperties.load(new BufferedInputStream(new FileInputStream(
					UTILFILE)));
			filenameProperties.load(new BufferedInputStream(
					new FileInputStream(FILENAME)));
			keyProperties.load(new BufferedInputStream(
					new FileInputStream(KEYFILE)));
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		keyword = utilProperties.get("keyword").toString().split(",");

	}

	public static void setProperties(String key, String value) {
		loyoutProperties.setProperty(key, value);
		FileOutputStream fos = null;
		try {
			fos = new FileOutputStream(LOYOUTFILE);
			loyoutProperties.store(fos, "");
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	// public static StringBuilder sb = new StringBuilder();
	//
	// public static String[] getStringArr(String text) {
	//
	// String[] array = null;
	// for (char c : text.toCharArray()) {
	// if(c != ' '){
	//
	// }
	// }
	// return array;
	// }

}
